<?php
/**
* YOOsearch Joomla! Module
*
* @author    yootheme.com
* @copyright Copyright (C) 2007 YOOtheme Ltd. & Co. KG. All rights reserved.
* @license	 GNU/GPL
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

global $mainframe, $Itemid;

// count instances
if (!isset($GLOBALS['yoo_searchs'])) {
	$GLOBALS['yoo_searchs'] = 1;
} else {
	$GLOBALS['yoo_searchs']++;
}

// include helper
require_once (dirname(__FILE__).DS.'helper.php');

// init vars
$set_itemid		 = $Itemid;
$field_text	     = $params->get('field_text', JText::_('search...'));
$box_width	     = $params->get('box_width', JText::_('400'));
$moduleclass_sfx = $params->get('moduleclass_sfx', '');
$module_base     = JURI::base() . 'modules/mod_yoo_search/';

// css parameters
$search_id   = 'yoo-search-' . $GLOBALS['yoo_searchs'];

$css_box_width        = 'width: ' . $box_width . 'px;';

// js parameters
$javascript = "new YOOsearch('" . $search_id . "', { 'setItemid': " . $set_itemid . ", 'fieldText': '" . $field_text . "' });";

require(JModuleHelper::getLayoutPath('mod_yoo_search', 'default'));

$document =& JFactory::getDocument();
$document->addStyleSheet($module_base . 'mod_yoo_search.css.php');
$document->addScript($module_base . 'mod_yoo_search.js');
echo "<script type=\"text/javascript\">\n// <!--\n$javascript\n// -->\n</script>\n";